import pymysql.cursors

# 连接数据库
connect = pymysql.Connect(host='localhost',port=3306,user='root',passwd='670980756',db='ayst_db_content',charset='utf8')

# 获取游标
cursor = connect.cursor()
#打印所有数据
cursor.execute("select audio_name,audio_path,release_time,show_order from audio_info where album_id = 1121392 ORDER BY show_order")

datalist=list(cursor.fetchall())

html=''
for row in datalist :

    audio_name = row[0]
    audio_path = "https://audio.aiyinsitanfm.com" + row[1]
    release_time = row[2].strftime("%Y-%m-%d %X")

    html+='<tr><td>'+audio_name+'</td><td><audio controls="controls" height="100" width="100" preload="none"><source src="'+audio_path+'" type="audio/mp3" /><source src="song.ogg" type="audio/ogg" /><embed height="100" width="100" src="'+audio_path+'" /></audio></td><td>'+release_time+'</td></tr>'

cursor.close()
connect.close()

print(html)
